﻿@model SportsStore.Domain.Enities.Product

@{
    ViewBag.Title = "后台：商品信息修改";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

<h3>修改</h3>

@using (Html.BeginForm("Edit","Admin",FormMethod.Post,new {enctype="multipart/form-data"}))
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>商品信息</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @Html.HiddenFor(model => model.ProductID)

        <div class="form-group">
            <label class="control-label col-md-2" for="Name">名称</label>
            <div class="col-md-10">
                @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-2" for="Description">描述</label>
            <div class="col-md-10">
                @Html.EditorFor(model => model.Description, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-2" for="Price">价格</label>
            <div class="col-md-10">
                @Html.EditorFor(model => model.Price, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-2" for="Category">类别</label>
            <div class="col-md-10">
                @Html.EditorFor(model => model.Category, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Category, "", new { @class = "text-danger" })
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2" for="Image">图片</label>
            <a class="btn" href="javascript:">选择一个图片 <input type="file" name="Image" onchange='$("#upload-fileinfo").html($(this).val());' /></a>
            <span class="label label-info" id="upload-file-info"></span>
            @if (Model.ImageData == null)
            {
                <div class="col-md-10 text-right">没有图片</div>
            }
            else
            {
                <img class="img-thumbnail" width="150" height="150" src="@Url.Action("GetImage","Product",new {productId=Model.ProductID})" />
            }
        </div>
        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="更新" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("返回到后台首页", "Index")
</div>
